<template>
  <div id="player">
      <!-- <h2 class="title">黑云音乐</h2> -->
      <el-carousel height="200px" >
        <el-carousel-item v-for="(item,index) in bannerImg" :key="'bn'+index">
          <img :src="item.imageUrl" alt="" style="width:100%;height: 100%;">
        </el-carousel-item>
      </el-carousel>
      <div class="search" style="margin-top: 10px;">
        <input type="text"  v-model="search" @keyup.enter="toFind"/>
        <button @click="toFind">
          <span class="iconfont icon-search"></span>
        </button>
      </div>
      <div class="tab-wrapper">
        <!-- tab栏 -->
        <div class="tab-bar">
          <router-link :to="'/result/'+search" class="bar-item " active-class="active" >搜索结果</router-link>
          <router-link :to="'/player/'+id" class="bar-item " active-class="active">歌曲播放</router-link>
          <router-link :to="'/video/'+mvid" class="bar-item " active-class="active" ref="unClick">mv</router-link>
          <router-link :to="'/comment/'+id+'&type=0'" class="bar-item " active-class="active">歌曲评论></router-link>
          <!-- <router-link to="/recommend" class="bar-item " active-class="active" >推荐歌曲</router-link> -->
        </div>
        <!-- 对应的内容区域 -->
        <div class="tab-content">

        </div>
      </div>
    </div>
</template>

<script>
export default {
  data(){
    return{
      bannerImg:[],
      search:'',
      id:'',
      mvid:''
    }
  },
  created(){
    // 歌曲id和mvid 传递4
    this.$eventBus.$on('keepSrc',(val)=>{
      this.id = val.id
      this.mvid = val.mvid
      // console.log('终点',val)
    })
    this.search = this.$route.params.id || ''
    // 获取banner 图片
    this.$axios.get('/banner').then(res=>{
      this.bannerImg = res.data.banners
      console.log(res)
    })
  },
  methods:{
    toFind(){
      this.$router.push('/result/'+this.search)
    },
  },
  watch:{
    mvid(){
      if(!this.mvid){
        this.$refs.onclick=function(){
          this.preventDefault()
          alert('当前歌曲没有mv')
        }
      }
    }
  }
}
</script>

<style scoped >
  @import '@/assets/css/index.css';
</style>
<style>
@import '@/assets/css/iconfont.css';</style>
